import { BaseApi } from "@/api-services/apis/baseApi";
import { SysRole, SysUser } from "@/api-services/models/system";
import { BaseIdInput } from "@/api-services/models/baseModels";
/**
 * 菜单管理Api
 */
class SysRoleApi extends BaseApi<SysRole.SysRoleInfo, SysRole.SysRoleInfo, SysRole.SysRoleInfo> {
  //角色选择
  roleSelector = async (data: object) => {
    return this.normalGet<Array<SysRole.RoleSelectorOutput>>(`/selector`, data);
  };
  //获取角色已分配资源
  getOwnResource = async (data: BaseIdInput) => {
    return this.normalGet<Array<SysRole.RoleResourceInfo>>(`/ownResource`, data);
  };
  //获取角色已分配菜单
  getOwnMenu = async (data: BaseIdInput) => {
    return this.normalGet<Array<Number>>(`/ownMenu`, data);
  };
  //获取角色已授权用户
  getOwnUser = async (data: BaseIdInput) => {
    return this.normalGet<Array<SysUser.UserSimpleInfo>>(`/ownUser`, data);
  };
  //获取角色已授权部门
  getOwnOrg = async (data: BaseIdInput) => {
    return this.normalGet<Array<Number>>(`/ownOrg`, data);
  };

  //分配菜单
  grantRoleMenus = async (data: SysRole.RoleMenusInput) => {
    return this.normalPost(`/grantRoleMenus`, data);
  };
  //授权用户
  grantRoleUsers = async (data: SysRole.RoleUsersInput) => {
    return this.normalPost(`/grantRoleUsers`, data);
  };
  //授权组织
  grantRoleOrgs = async (data: SysRole.RoleOrgsInput) => {
    return this.normalPost(`/grantRoleOrgs`, data);
  };
  //分配资源
  grantRoleResource = async (data: SysRole.RoleResourceInput) => {
    return this.normalPost(`/grantRoleResource`, data);
  };
}

export default new SysRoleApi("/system/role");
